//获取应用实例
const app = getApp()
Page({
  data: {
    id:"",
    indicatorDots: true,
    vertical: true,
    autoplay: false,
    circulars: true,
    interval: 3000,
    duration: 1500,
    winWidth: 0,
    winHeight: 0,
    // tab切换
    currentTab: 0,
    goodsimg:[],
    price:"",
    desc:"",
    honest: "",
    newnessLevel: "",
    viewCount: "",
    comment:[{
      headingImg: '../../../images/leaseImg/4.jpg',
      commentname:"匿名",
      time: "10秒前",
      new: '好看倒萨u盾哈市简单化'
    },
      {
        headingImg: '../../../images/leaseImg/2.jpg',
        commentname: "匿名",
        time: "1分钟前",
        new: 'sdhahduahdjsnadshansjdasjh'
      }
    ]
  
  },
  //获取当前滑块的index
  bindchange: function (e) {
    const that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
  //点击切换，滑块index赋值
  checkCurrent: function (e) {
    const that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
      })
    }
  },
  /*加载上页传来的id*/
  onLoad: function (options) {
    
    this.setData({
      id: options.id
    })

  },
  /*页面再次加载 */
  onReady:function(){
    this.detailsPage()
  },
  detailsPage: function (e){
    var a = this.data.id
    console.log(a)
    var app = this;
    wx.request({
      url: 'https://www.gxjyxq.cn/item/detail',
      data: {
        itemId: a,
      },
      method: 'get',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        app.setData({
          price: res.data.price,
          desc: res.data.desc,
          honest: res.data.seller.honest,
          newnessLevel: res.data.newnessLevel,
          viewCount: res.data.viewCount,
          goodsimg: res.data.images
        })
      }
    })

  },
  /**传递id值给下个页面 */
  rander: function (e) {
    var a = this.data.id
    console.log(a)
    wx.navigateTo({
      url: '../BuyPage/BuyPage?id='+a,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  }
})
